package com.teach.shape1;

import java.util.Scanner;

/**
 * 正方形
 * @author J.L.Zhou
 *	jlzhou.top 版权所有
 */
public class Square {
	private static final String NAME = "正方形";
	/**
	 * 宽
	 */
	private float width;
	
	
	/**
	 * 周长
	 */
	private float perimeter;
	
	/**
	 * 面积
	 */
	private float area;

	public void input(Scanner sc) {
		System.out.println("输入"+NAME+"的边长: ");
		width = sc.nextFloat();

		
		perimeter = width *4;
		area = width*width;
	}
	

	/**
	 * 获取周长
	 * @return 周长
	 */
	public float getPerimeter(){
		return perimeter;
	}

	/**
	 * 获取面积
	 * @return
	 */
	public float getArea(){
		return area;
	}

	/**
	 * 打印基本信息
	 */
	public void show() {
		System.out.format("%s\t周长：%.2f\t面积：%.2f\t边长：%.2f\n",NAME,perimeter,area,width);

	}

	public float getWidth() {
		return width;
	}

	public void setWidth(float width) {
		this.width = width;
	}

	
	public static void main(String[] args) {
		Square rectangle = new Square();
		rectangle.input(new Scanner(System.in));
		rectangle.show();
	}

}
